**********************************************************************************************
* Reproduces Table A9
*
* Ajzenman, Elacqua, Jaimovich and Pérez-Núñez (2024)."Humans versus Chatbots: Scaling-up behavioral interventions to reduce teacher shortages"  	  		
*
**********************************************************************************************

preserve

*Identify spillover effect. EXPLICAR QUE ES TIPO CURSO Y CADA VALOR QUE TOMA 
gen treatment1 = .
replace treatment1= 1 if tipo_curso==1
replace treatment1= 0 if inlist(tipo_curso,4,8)


////PANEL A: 

reg education_rankfirst treatment1 education_preference sexo i.dependencia_colegio top_30 per_interesado_curso n_clase_ren,r
estadd ysumm 
outreg2 using "${output}/TableA9a.tex", replace sdec(4) tex  keep(treatment1)  addstat(Mean of dependent variable, e(ymean)) label nocons


foreach var in education_proportion education_listed d_enroll_education{
	
reg `var' treatment1 education_preference sexo i.dependencia_colegio top_30 per_interesado_curso n_clase_ren,r
estadd ysumm 
outreg2 using "${output}/TableA9a.tex", append sdec(4) tex  keep(treatment1)  addstat(Mean of dependent variable, e(ymean)) label nocons
eststo clear
}



////PANEL B
*drope classes with bot and human treated.  EXPLICAR QUE ES TIPO CURSO Y CADA VALOR QUE TOMA 
drop if tipo_curso==8

*  EXPLICAR LA INTERACCION
gen inter_bot = n_bot_curso*bot
gen inter_humano = n_humano_curso*humano

keep if inlist(grupo_det,"Humano", "Control A")


reg education_rankfirst i.grupo_gen inter_humano n_humano_curso sexo i.dependencia_colegio top_30 per_interesado_curso n_clase_ren ,r
estadd ysumm 
outreg2 using "${output}/TableA9b.tex", replace sdec(4) tex  keep(i.grupo_gen inter_humano)  addstat(Mean of dependent variable, e(ymean)) label nocons 


foreach var in education_proportion education_listed d_enroll_education{
	
reg `var' i.grupo_gen inter_humano n_humano_curso sexo i.dependencia_colegio top_30 per_interesado_curso n_clase_ren ,r
estadd ysumm 
outreg2 using "${output}/TableA9b.tex", append sdec(4) tex  keep(i.grupo_gen inter_humano)  addstat(Mean of dependent variable, e(ymean)) label nocons

}
restore 

*Note: Calculations of the significant difference in the bot vs human effect were manually added to the table according to the results produced by the commands run earlier in this code.